package demoMod.stsconsole.powers;

import demoMod.stsconsole.core.AbstractCreature;
import demoMod.stsconsole.interfaces.BlockSubscriber;

public class DexterityPower extends AbstractPower implements BlockSubscriber {
    public static final String ID = "DexterityPower";

    public DexterityPower(AbstractCreature owner, int amount) {
        super(ID, owner, amount);
        if (amount > 0) {
            this.type = PowerType.BUFF;
        } else {
            this.type = PowerType.DEBUFF;
        }
    }

    @Override
    public void stackAmount(int[] amount) {
        super.stackAmount(amount);
        if (this.amount[0] <= 0) {
            this.type = PowerType.DEBUFF;
            if (this.amount[0] == 0) {
                this.onRemove();
            }
        } else {
            this.type = PowerType.BUFF;
        }
    }

    @Override
    public String getUpdatedDescriptions() {
        if (this.amount[0] >= 0) {
            return String.format(this.description, this.amount[0]);
        } else {
            return String.format(this.powerStrings.get(2), -this.amount[0]);
        }
    }

    @Override
    public int onDefendToChangeBlock(int blockAmount, AbstractCreature target) {
        return blockAmount + this.amount[0];
    }
}
